package com.hon.legionnaire.negocio.vo;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "usuario")
@NamedQueries ({
	@NamedQuery(name = "loadAllUsuario", query = "from UsuarioVO as u order by u.usuario"),
	@NamedQuery(name = "findUsuario", query = "from UsuarioVO as u where u.usuario = :usuario and u.senha = :senha"),
	@NamedQuery(name = "findUsuarioPorFuncionario", query = "from UsuarioVO as u where u.funcionarioVO.codigo = :cod_funcionario"),
	@NamedQuery(name = "findDuplicatedUsuario", query = "from UsuarioVO as u where u.funcionarioVO.codigo = :cod_funcionario and u.usuario != :usuario")
})
public class UsuarioVO implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "usuario", nullable = false, length = 50)
	private String usuario;
	
	@Column(name = "senha", nullable = false, length = 50)
	private String senha;
	
	@Column(name = "perfil", nullable = false, length = 50)
	private String perfil;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "cod_funcionario", nullable = false)
	@Fetch(FetchMode.JOIN)
	private FuncionarioVO funcionarioVO;
	
	public UsuarioVO() {

	}
		
	public String getUsuario() {
		return this.usuario;
	}

	public void setUsuario(String usuario) {
		this.usuario = usuario;
	}

	public String getSenha() {
		return this.senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public String getPerfil() {
		return this.perfil;
	}

	public void setPerfil(String perfil) {
		this.perfil = perfil;
	}

	public FuncionarioVO getFuncionarioVO() {
		return funcionarioVO;
	}

	public void setFuncionarioVO(FuncionarioVO funcionarioVO) {
		this.funcionarioVO = funcionarioVO;
	}
}